getApp();

//app.js
App({
    show: function(n, a, i) {
        var t = wx.createAnimation({
            duration: 500,
            timingFunction: "ease"
        });
        t.opacity(i).step();
        var l = '{"' + a + '":""}';
        (l = JSON.parse(l))[a] = t.export(), n.setData(l);
    },
    onLaunch: function(n) {
        var a = this, i = wx.getStorageSync("logs") || [];
        i.unshift(Date.now()), wx.setStorageSync("logs", i), wx.login({
            success: function(n) {}
        }), wx.request({
            url: "https://224diy.com/admin/php/call.php?id=6",
            success: function(n) {
                a.globalData.yulanbeijing = n.data;
            }
        }), wx.request({
            url: "https://224diy.com/admin/php/call.php?lx=2&name=%E7%94%9C%E8%9C%9C%E6%83%85%E8%AF%9D",
            success: function(n) {
                a.globalData.yulanwenan = n.data;
            }
        }), wx.request({
            url: "https://224diy.com/admin/php/call.php?id=5",
            success: function(n) {
                a.globalData.yulanyinyue = n.data;
            }
        }), wx.request({
            url: "https://224diy.com/admin/php/call.php?id=7",
            success: function(n) {
                a.globalData.yulanpeitu = n.data;
            }
        });
    },
    globalData: {
        linkplaceholder: "",
        linkmoshi: "(当前信封模式)",
        linkwenan: "尽管没有深情的告白，也没有诚挚的诺言，但在顺其自然中我们就成为了彼此的唯余生漫漫，我愿与你风雨中执手，平淡中偕老。",
        linkbeijing: "https://inews.gtimg.com/newsapp_ls/0/13396300229/0",
        linkpeitu: "https://inews.gtimg.com/newsapp_ls/0/13375976707/0",
        linkmusicurl: "https://224diy.com/api/163/1409382131.mp3",
        linkgeming: "(摩天动物园 - 邓紫棋)",
        linkpassword: "1314",
        linkfontcolor: "#000",
        linkfontsize: "35",
        linkfontspeed: "150",
        linkcolorvalue: "(默认磨砂黑色)",
        linkyulanback: "https://inews.gtimg.com/newsapp_ls/0/13396300229/0",
        linkfontcolor2: "#000",
        yulanbeijing: [],
        yulanwenan: [],
        yulanyinyue: [],
        yulanpeitu: [],

        user_id: 7001,
        appid: "wx403b4723a4bd60b9"
    },
    api_root: "",
    onLaunch: function() {
        wx.setStorageSync("token", "6fdde68c99851a5126a8d8d222f99db3"), wx.setStorageSync("user_id", 7001), 
        this.setApiRoot(), this.getWxappBase();
    },
    onShow: function(t) {},
    setApiRoot: function() {
        this.api_root = e.default.siteroot + "index.php?s=/api/";
    },
    getWxappBase: function(t) {
        this._get("wxapp/base", {}, function(o) {
            console.log(o.token), wx.setStorageSync("token", o.token), wx.setStorageSync("user_id", o.user_id), 
            wx.setStorageSync("wxapp", o.data.wxapp), t && t(o.data.wxapp);
        }, !1, !1);
    },
    doLogin: function() {
        var t = getCurrentpages1();
        if (t.length) {
            var o = t[t.length - 1];
            "pages1/login/login" != o.route && wx.setStorageSync("currentPage", o);
        }
        wx.navigateTo({
            url: "/pages1/login/login"
        });
    },
    getUserId: function() {
        return wx.getStorageSync("user_id") || 0;
    },
    showSuccess: function(t, o) {
        wx.showToast({
            title: t,
            icon: "success",
            success: function() {
                o && setTimeout(function() {
                    o();
                }, 1500);
            }
        });
    },
    showError: function(t, o) {
        wx.showModal({
            title: "友情提示",
            content: t,
            showCancel: !1,
            success: function(t) {
                o && o();
            }
        });
    },
    _get: function(t, o, e, n, i, a) {
        var r = this;
        wx.showNavigationBarLoading(), o = Object.assign({
            wxapp_id: 10001,
            token: wx.getStorageSync("token"),
            appid: r.globalData.appid
        }, o);
        var s = function() {
            o.token = wx.getStorageSync("token");
        };
        a ? r.doLogin(s) : s();
    },
    _post_form: function(t, o, e, n, i) {
        wx.showNavigationBarLoading();
        var a = this;
        o = Object.assign({
            wxapp_id: 10001,
            token: wx.getStorageSync("token"),
            appid: a.globalData.appid
        }, o);
    },
    validateUserInfo: function() {
        return wx.getStorageSync("user_info"), !!wx.getStorageSync("user_info");
    },
    urlEncode: function(t) {
        var o = [];
        for (var e in t) {
            var n = t[e];
            n.constructor == Array ? n.forEach(function(t) {
                o.push(e + "=" + t);
            }) : o.push(e + "=" + n);
        }
        return o.join("&");
    },
    setTitle: function() {},
    setNavigationBar: function() {
        this.getWxappBase(function(t) {
            wx.setNavigationBarColor({
                frontColor: t.navbar.top_text_color.text,
                backgroundColor: t.navbar.top_background_color
            });
        });
    },
    getTabBarLinks: function() {
        return n;
    },
    checkIsLogin: function() {
        return "" != wx.getStorageSync("token") && "" != wx.getStorageSync("user_id");
    },
    getUserInfo: function(t, o) {
        var e = this;
        if ("getUserInfo:ok" !== t.detail.errMsg) return !1;
        wx.showLoading({
            title: "正在登录",
            mask: !0
        }), wx.login({
            success: function(n) {
                e._post_form("user/login", {
                    code: n.code,
                    user_info: t.detail.rawData,
                    encrypted_data: t.detail.encryptedData,
                    iv: t.detail.iv,
                    signature: t.detail.signature
                }, function(t) {
                    wx.setStorageSync("token", t.data.token), wx.setStorageSync("user_id", t.data.user_id), 
                    o && o();
                }, !1, function() {
                    wx.hideLoading();
                });
            }
        });
    }
  })

